import { defineStore } from 'pinia'
import { RouteRecordRaw } from 'vue-router'
// import { useRouter } from 'vue-router';
import route from '@/router/route'
export const useMenus = defineStore('userMenus',{
    persist: {
        storage:localStorage,
        key:'USER_INFO',
        serializer: { 
          deserialize: JSON.parse, //JSON.parse
          serialize: JSON.stringify//JSON.stringify
        }
    },
    state:()=>({
        routes:[] as Array<RouteRecordRaw>,
        activeRouter:"/home"
    }),

    getters:{
        getRouter:state=>state.routes,
        getactiveRouter:state=>state.activeRouter,
    },

    actions:{
        setRouter(){
            // const router = useRouter();
            this.routes =  route//router.getRoutes();
        },
        setActiveRouter(url:string){
            this.activeRouter = url
        }
    }
})